/**
 * 2016，thor.com，all rights reserved。
 * 
 * Project：		palmmall-core
 * Filename：	AStoreQueryParamConverter.java
 * Created：		2016年9月5日
 * Creator：		wolv
 */
package com.thor.palmmall.rest.common;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.entity.UCN;
import com.thor.palmmall.spi.common.SSubjectWithDirection;

/**
 * @author wolv
 *
 */
public class SSubjectWithDirectionConverter implements Converter<ASubjectWithDirection, SSubjectWithDirection> {

	public static SSubjectWithDirectionConverter getInstance() {
		if (instance == null)
			instance = new SSubjectWithDirectionConverter();
		return instance;
	}

	private static SSubjectWithDirectionConverter instance;

	private SSubjectWithDirectionConverter() {
	}

	@Override
	public SSubjectWithDirection convert(ASubjectWithDirection source) {
		if (source == null)
			return null;

		SSubjectWithDirection target = new SSubjectWithDirection();
		target.setDirection(source.getDirection());
		target.setSubject(UCN.newInstance(source.getSubject()));

		return target;
	}

}
